Skip to content

Add a visual clue to indicate the projectiles are about to dissapear - #2801

Open
Salonso928 wants to merge 3 commits into
endlessm:mainfrom
Salonso928:main
Open

Add a visual clue to indicate the projectiles are about to dissapear#2801
Salonso928 wants to merge 3 commits into
endlessm:mainfrom
Salonso928:main

Conversation

@Salonso928

@Salonso928 Salonso928 commented Aug 28, 2026

Copy link
Copy Markdown

Affected scene: res://scenes/quests/template_quests/NO_EDIT/2_NO_EDIT_combat/NO_EDIT_combat_components/NO_EDIT_projectile.tscn
Affected script: res://scenes/game_elements/props/projectile/components/projectile.gd

When a projectile has spent the 80% of its duration, a dissapear animation will start. While this animation is playing the proyectile can be interacted with the repel comand and all Area2D nodes if posible, but this will no longer reset its duration.
An AnimationPlayer was added to the projectile scene and imported using the @onready annotation in the projectile.gd

image
Videocaptura.de.pantalla_20260827_193240.mp4

Fixes #2442

@Salonso928
Salonso928 requested review from a team as code owners August 28, 2026 00:46
@Salonso928 Salonso928 changed the title Add a visual clue to indicate the projectiles are about to dissapear #2442 Add a visual clue to indicate the projectiles are about to dissapear Issue#2442 Aug 28, 2026
@Salonso928 Salonso928 changed the title Add a visual clue to indicate the projectiles are about to dissapear Issue#2442 Add a visual clue to indicate the projectiles are about to dissapear Aug 28, 2026
@github-actions

Copy link
Copy Markdown

Play this branch at https://play.threadbare.game/branches/Salonso928/main/.

(This launches the game from the start, not directly at the change(s) in this pull request.)

@manuq manuq left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The work you did looks good for the NO_EDIT_combat.tscn, which uses the NO_EDIT_projectile.tscn. But not with other projectiles, like ink_blob_projectile.tscn or any other projectile in StoryQuests.

I have more to comment about the visual clue (which is a great start, by the way), but let's fix this first!

time_passed+=_delta
if time_passed>= time_to_dissapear && not is_dissapearing:
is_dissapearing=true
animation_player.play("dissapear")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This crashes the game if you play res://scenes/quests/lore_quests/quest_000/4_ink_combat/tutorial_ink_combat.tscn with:

E 0:00:08:038   projectile.gd:71 @ @implicit_ready(): Node not found: "%AnimationPlayer" (relative to "/root/TutorialInkCombat/InkBlobProjectile").
E 0:00:12:055   Projectile._process: Cannot call method 'play' on a null value.

…effect is only controlled by the projectile.gd script
@Salonso928

Copy link
Copy Markdown
Author

Hi @manuq I made some changes. I removed the AnimationPlayer node, now the blink effect is only controlled by the projectile.gd script, therefore all the scenes that use this script should display the effect.
Here is a video playing ink_combat_round_4.tscn

Videocaptura.de.pantalla_20260828_120009.mp4

@Salonso928
Salonso928 requested a review from manuq August 30, 2026 18:59

@manuq manuq left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, although I think that the projectile should blink a predictable amount of times, let's say 3 blinks by default before dissapearing. Sorry that it wasn't part of the specification!

I understand that you switched from AnimationPlayer to make the blink programmatically because, as you saw, your first attempt changed only one of the 18 projectile scenes currently in the game.

There are pros and cons of doing it programmatically: the main benefit is that changing the script changes all 18 at the same time, great! But it leaves all the projectiles with the same look and feel. Someone wanting a different blink effect will need to duplicate the script. And artists wanting to improve the effect will be more comfortable editing it in an AnimationPlayer. Also we may want to add a sound effect in addition to the blink as audio clue.

Is fine if you want to keep doing it programmatically. I may add a followup ticket to move to AnimationPlayer. If so, check my suggestion to switch to Tween.

Alternatively, if you want to go back to AnimationPlayer you can make it optional, and add AnimationPlayer nodes to the NO_EDIT_projectile.tscn and the ink_blob_projectile.tscn, leaving the others (all StoryQuests) as before (without blink effect). For making it optional, you should not set a unique name (as I suggested before):

@onready var animation_player: AnimationPlayer = %AnimationPlayer

Because that will fail with Node not found: "%AnimationPlayer" in the scenes that don't have it. Instead you can export a new property:

@export var blink_animation_player: AnimationPlayer

Under @export_group("FXs"). And assign it in the 2 scenes mentioned above.

##the effect will start when the projectile has spent 70% of its lifetime
time_to_dissapear = duration * 0.7

blink_timer = Timer.new()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using a Timer node to do the blinking, it would be better to use a Tween.

But this leads to my main feedback, whether or not to animate the blink effect programmatically. I'll comment about it separately.

Comment on lines +144 to +145
time_passed += _delta
if time_passed >= time_to_dissapear && not is_dissapearing:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DurationTimer node is already tracking the time, you could check its time_left property. Or even better, create a separate Timer for this, and call it StartBlinkingTimer.

The _ready() method already does:

	duration_timer.wait_time = duration
	duration_timer.start()

So that's the place to setup the new timer:

	duration_timer.wait_time = duration
	duration_timer.start()
	start_blinking_timer.wait_time = duration - blink_times * blink_duration

@manuq

manuq commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

The lint and format checks are failing too for boring reasons (new lines and spacing). Please consider installing pre-commit as explained here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Projectiles: add clue to indicate that they are about to disappear

2 participants